package com.yfproject.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.yfproject.models.Course;
import com.yfproject.models.Student;
import com.yfproject.service.impl.ManyToManyImpl;



@RestController
public class SlectingCourseController {
	
	@Autowired
	ManyToManyImpl manyToManyImpl;
	
	@RequestMapping("/qryStudent/{sid}")
	public Student qryStudent(@PathVariable Integer sid) {
		return manyToManyImpl.findBySid(sid);
	}

	@RequestMapping("/qryCourse/{cid}")
	public Course qryCourse(@PathVariable Integer cid) {
		return manyToManyImpl.findByCid(cid);
	}
	
	@RequestMapping(value = "/slectingCourse",method = RequestMethod.POST)
	public void slectingCourse(@RequestParam(value = "sid", required = true) Integer sid,
			@RequestParam(value = "cid", required = true) Integer cid) {
		manyToManyImpl.slectingCourse(sid,cid);
	}
	
	@RequestMapping(value = "/delCourse",method = RequestMethod.POST)
	public void delCourse(@RequestParam(value = "sid", required = true) Integer sid,
			@RequestParam(value = "cid", required = true) Integer cid) {
		manyToManyImpl.delCourse(sid, cid);
	}
	
	@RequestMapping(value = "/insertStu",method = RequestMethod.POST)
	public void insertStu(@RequestParam(value = "name", required = true) String name) {
		manyToManyImpl.insertStu(name);
	}
	
	@RequestMapping(value = "/insertCou",method = RequestMethod.POST)
	public void insertCou(@RequestParam(value = "name", required = true) String name) {
		manyToManyImpl.insertCou(name);
	}
}
